from alipay import AliPay
from django.conf import settings
import os


def get_alipay():
    alipay = AliPay(
        appid=settings.ALIPAY_APPID,
        app_notify_url=None,  # 默认回调url
        app_private_key_path=os.path.join(settings.BASE_DIR, 'apps/payments/keys/app_private_key.pem'),
        alipay_public_key_path=os.path.join(settings.BASE_DIR, 'apps/payments/keys/alipay_public_key.pem'),
        sign_type="RSA2",  # RSA 或者 RSA2
        debug=settings.ALIPAY_DEBUG  # 默认False
    )
    return alipay
